home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk G-S 128
/
SGDS 128.2mg
/
SDGS.128
/
SDC128
/
C
/
APE.DOC#040000
< prev
next >
Wrap
Text File
|
1992-07-25
|
45KB
|
937 lines
Apple Program Environment
Douglas B. Eamon
Department of Psychology
University of Wisconsin - Whitewater
Whitewater, WI 53190
The "desktop metaphor," including pulldown menus and windows described in
Apple's Human Interface Guidelines, has become a preferred, if not standard,
program environment for many applications. While commonly seen on the Apple
IIgs, Mac, and IBM, they have remained largely unused by Applesoft programmers
on the IIe and IIc, primarily because of the difficulty in implementing them
from that language.
This file describes a simple yet powerful menu/window programming
environment for Applesoft users. The program functions in 80-column text mode
only. It will work on any of the Apple II family which supports mouse
characters, including the Apple IIgs (although it does not use the IIgs's
toolbox menu and window functions), IIc, or enhanced IIe. With some revision,
it could also work on an unenhanced IIe or even a II+, provided the user is
willing to substitute other characters for mouse characters used as frames for
the menus and windows.
The assembly language program which provides these functions is called
Apple Program Environment, or APE. In addition to allowing pulldown menus
and multiple windows, APE includes a command interpreter, a text printing
utility, and an "input anything" utility. The command interpreter allows the
program user to select an option without using the pulldown menus, for
example, by pressing the open-Apple key along with a keyboard character. The
text printing utility prints text within the currently defined window with
word wrapping.
APE is easy to use, flexible, and compact. An Applesoft program using
APE can allow the program user to use the arrow keys to select an option
from a menu bar or a pulldown menu, get a command from the keyboard, open or
close a window, or print text within a window. APE executes the function
and returns any appropriate values (e.g., the menu item selected) to
Applesoft.
The general form of a command to APE is
CMND, parm1, parm2, ..., parmN where
CMND is the command you want to execute and parm1, parm2, etc., are values
used by APE (e.g., menu items, screen locations for a window to be
opened).
The commands and their functions are as follows:
Command Function
M Print a menu and allow the user to select
a menu option or input a keyboard command
GET Present an input prompt and get the user's
selection of a keyboard command; accept only
keys passed to the routine
WBP Clear a screen window area and save the screen
contents in a string array using the "packed"
format; make a window with borders and print a
title (if given) centered in the top border
WBU Same as WBP, except save in unpacked format
WNP Clear window area and save screen in packed
format, but do not print border or title
WNU As above, but use unpacked format
WSP Save screen to array in packed format, but
do not clear screen, draw border or print title
WSU As above, unpacked format
WRD Remove a window by restoring the contents of the
screen to their previous state, then delete the
storage array from memory
WRK Remove a window and restore screen, but do not
delete the storage array from memory
PRINT Print text in currenty defined window with
word wrapping
INPUT Input a line which might include commas, quotes,
etc.
CLEAR Clear the screen with the character(s) passed to
the routine.
APE may be implemented using either the ampersand (&) command, or the
CALL address command if the ampersand command is already in use. For
simplicity, I assume that the ampersand is being used. APE is
compatible with both DOS 3.3 and ProDOS. It is 2455 bytes long.
Menus
APE's pulldown menu is "traditional"-looking and appears much like
those found on the Mac and Apple IIgs, except that it is entirely text-based
(although it will display mouse characters). A "menu bar" in inverse video is
shown at the top of the screen in which the current item is highlighted by
printing it in normal video. The pulldown menus are presented by pressing
<RETURN> or the down arrow key; pulldown item selections are displayed in
normal video, except the current item, which is highlighted in inverse video.
The pulldown items are presented in a frame aligned with the left edge of the
menu bar selection. The current item (whether in the main menu or a pulldown
menu) can also be made to blink (not flash) on and off at a preselected
speed.
The command syntax used to display a menu and obtain the user selection
is:
& M, MAIN, SUB, ME$(0) [,BS] where
The "M" instructs APE to perform the menu function; MAIN, SUB, and
ME$(0), are user-defined variables, and BS is a user-defined variable or
constant. M may be a variable in your program, but is not interpreted as such
by APE, and its value will not be altered by APE.
MAIN is the main (menu bar) selection. If MAIN = 0, the menu bar will be
printed (with no items highlighted), and the routine will immediately return.
This is useful if you just want to print the menu bar and go on to do other
things; the menu bar provides a reference frame for the rest of the program.
If MAIN > 0, the corresponding menu bar item will be highlighted. When the
user makes a selection from the menu bar, MAIN is used to return the selection
to the program.
SUB is the submenu (pulldown menu) selection. If MAIN > 0 and SUB > 0,
the submenu items will be displayed in a pulldown menu with item SUB
highlighted (displayed in inverse video, blinking), and the program will wait
for user input. If SUB = 0, the submenu will not be pulled down. SUB is also
used to return the users selection of the pulldown item.
ME$(0) is a string array which contains the menu items in elements 1 - n,
where n is the number of main menu items. Element 0 of the array may contain
keyboard commands to be interpreted by APE. These may be alternative ways
of selecting menu items or entirely different commands. Keyboard commands are
discussed below under "Command Interpreter."
BS is an optional variable which controls the "blinking speed," or rate
at which the menu items will blink on and off while the program waits for user
input. Larger values create longer delays between blinks. To prevent
blinking, set this value to 0, or leave it out of the list of parameters.
When the user makes a selection from the menu, the pulldown menu is
closed, MAIN and SUB are reset to the new selection and the routine returns to
Applesoft. The program user makes his or her selection from the main menu
level by moving the arrow keys left or right; to display the associated
pulldown menu, the user can press either RETURN or the down arrow. If there
are no pulldown items the down arrow is ignored; a RETURN causes the main item
to be selected, and APE returns with its value to the calling Applesoft
program. If pulldown items are defined, the user can move up and down the
pulldown menu using the up and down arrows; pressing RETURN selects the item
and APE returns the value of the main menu item and the pulldown item to
the calling program. If the user presses a left or right arrow while on a
pulldown item, the pulldown menu is closed and the next main menu item is
highlighted.
If the user presses an acceptable keyboard command (see the information
on the Command Interpreter, below) while the menu command is active, any
pulldown menus are closed, MAIN is set to 0 and SUB is set to the the number
of the command.
Defining a menu
In order to use APE's menu routine, you need to define a set of menu
i